const fs = require("fs");
const path = require("path");
function getAllFile(dirPath) {
  const files = fs.readdirSync(dirPath);

  let arrayOfFiles = [];

  files.forEach(function (file) {
    const filePath = path.join(dirPath, file);
    const dirname = path.basename(filePath);
    // console.log({ dirname });
    if (fs.statSync(filePath).isDirectory()) {
      if (!dirname.startsWith("_") && dirname != "components") {
        arrayOfFiles = [...arrayOfFiles, ...getAllFile(filePath)];
      }
    } else {
      arrayOfFiles.push(filePath);
    }
  });

  return arrayOfFiles;
}
function getEntryFile() {
  const pages = {};
  const allFiles = getAllFile("example");
  console.log({allFiles})
  allFiles.forEach((key, index) => {
    const [, ...p] = key.split(".")[0];
    console.log(p.join("/"));
    pages[path.basename(p.join("/"))] = path.resolve(__dirname, "../", key);
  });
  console.log({ pages });

  return pages;
}
// getEntryFile()
module.exports = {
  getEntryFile,
};
